package runner

import (
	"gitee.com/gitee-go/core"
	"gitee.com/gitee-go/core/runtime"
)

type mpCliFun func(prt *Manager, msg *runtime.ClientMsg)

// 数据包任务分发
var mpCliFn = map[string]mpCliFun{
	"heart":    onHeart,
	"job/stop": stopJob,
}

func onHeart(prt *Manager, msg *runtime.ClientMsg) {
	core.Log.Debug("get server heart!!")
}

func stopJob(prt *Manager, msg *runtime.ClientMsg) {
	if msg.Head == nil {
		return
	}
	jobid := msg.Head.GetString("jobid")
	if jobid == "" {
		return
	}
	task, ok := prt.lines[jobid]
	if !ok {
		return
	}
	task.Stop()
}
